﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace sy2_7
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            string first10Terms = "1 + 1/2 + 1/4 + 1/7 + 1/11 + 1/16 + 1/22 + 1/29 + 1/37 + 1/46 + …";
            txtExpression.Text = first10Terms;
        }


        private void btnCalculate_Click(object sender, EventArgs e)
        {
            double sum = 1.0;
            int n = 1;
            int denominator = 1;
            int diff = 1; 

            double term = 1.0 / 2;
            denominator = 2;
            diff = 1;

            while (term >= 1e-4)
            {
                sum += term;
                n++;

                diff++;
                denominator += diff;
                term = 1.0 / denominator;
            }

            txtSum.Text = sum.ToString();
            txtN.Text = n.ToString();
        }
    }
}
